package com.example.radiationarea.compat;

import com.example.radiationarea.RadiationAreaMod;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = RadiationAreaMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class BiomesOPlentyCompat {
    public static final String MODID = "biomesoplenty";
    
    /**
     * 检查Biomes O' Plenty模组是否已加载
     * @return 如果模组已加载返回true，否则返回false
     */
    public static boolean isLoaded() {
        return ModList.get().isLoaded(MODID);
    }
    
    /**
     * 获取Biomes O' Plenty模组的版本
     * @return 模组版本字符串，如果模组未加载则返回空字符串
     */
    public static String getVersion() {
        if (!isLoaded()) {
            return "";
        }
        return ModList.get().getModContainerById(MODID)
                .map(container -> container.getModInfo().getVersion().toString())
                .orElse("");
    }
    
    /**
     * 在这里可以添加与Biomes O' Plenty的特殊兼容性处理
     * 例如添加特定的生物群系特征或地表规则
     */
    public static void setupCompat() {
        RadiationAreaMod.LOGGER.info("Biomes O' Plenty detected (version: {}). Enabling compatibility features.", getVersion());
        
        // 可以在这里添加特殊的兼容性逻辑
        // 例如：在Biomes O' Plenty的生物群系中添加辐射矿石
        // 或者创建特殊的混合生物群系等
    }
    
    @SubscribeEvent
    public static void onCommonSetup(FMLCommonSetupEvent event) {
        if (isLoaded()) {
            event.enqueueWork(() -> {
                setupCompat();
            });
        }
    }
}